const hallSeat = {
  state: {
    x: 0, y: 0, templeteName: null, templetePrice: null, confirmButtonLoading: false, reset: false,
    fullscreen: false,
    seatList: [],
    region: {},
    getSeattypecolor: []
  },
  mutations: {
    changeX (state, x) {
      state.x = x
    },
    changeY (state, y) {
      state.y = y
    },
    changeTempleteName (state, templeteName) {
      state.templeteName = templeteName
    },
    changeTempletePrice (state, templetePrice) {
      state.templetePrice = templetePrice
    },
    changeConfirmButtonLoading (state, confirmButtonLoading) {
      state.confirmButtonLoading = confirmButtonLoading
    },
    changeReset (state, reset) {
      state.reset = reset
    },
    makeFullscreen (state, fullscreen) {
      state.fullscreen = fullscreen
    },
    upNc (state, name) {
      state.region = name
    },
    allPullSeat (state, list) {
      state.seatList = list
    },
    setSeatList (state, ov) {
      let arr = ov.listseat.map((i) => {
        return {
          x_axis: i.x,
          y_axis: i.y,
          ticket_type: i.type,
          colour: i.backimg,
          pitch_on_color: i.pitch_on_color,
        };
      });
      state.seatList.forEach(i => {
        if (i.id == ov.id) {
          i.listseat = arr
          i.areaname = ov.areaname
        }
      })
    },
    addSeatList (state, obj) {
      state.seatList.push(obj)
    },
    delSeatList (state, obj) {
      state.seatList = state.seatList.filter(i => i.id != obj.id)
    },
    setSeattypecolor (state, list) {
      state.getSeattypecolor = list
    }
  },
  actions: {
    clearHallSeat ({ commit }) {
      return new Promise((resolve, reject) => {
        setTimeout(() => {
          commit('changeX', 0)
          commit('changeY', 0)
          commit('changeTempleteName', null)
          commit('changeTempletePrice', null)
          commit('changeConfirmButtonLoading', false)
          commit('changeReset', false)
          resolve()
        }, 16)
      })
    }
  },
  getters: {}
}

export default hallSeat;